package com.qi.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {

    @Bean
    public GroupedOpenApi receptionApi() {
        String[] paths = {"/recep/**"};
        String[] packagedToMatch = {"com.qi.controller"};
        return GroupedOpenApi.builder().group("前台接口")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean
    public GroupedOpenApi backofficeApi() {
        String[] paths = {"/admin/**"};
        String[] packagedToMatch = {"com.qi.controller"};
        return GroupedOpenApi.builder().group("后台接口")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean
    public OpenAPI customOpenAPI() {
        Contact contact = new Contact();
        contact.setName("朱安琦");
        contact.setEmail("你的邮箱");
        contact.setUrl("你的网址");

        return new OpenAPI().info(new Info()
                .title("Community Management System API Doc")
                .description("社团管理系统接口文档")
                .version("1.0")
                .contact(contact)
        );
    }
}